import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { GoodsUserProductPriceEntity } from '../../entity/userPrice';
import { GoodsUserPriceService } from '../../service/userPrice';
import { GoodsInfoEntity } from '../../entity/info';
import { UserInfoEntity } from '../../../user/entity/info';

/**
 * 用户商品专属价格
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: GoodsUserProductPriceEntity,
  service: GoodsUserPriceService,
  pageQueryOp: {
    fieldEq: ['a.userId', 'a.goodsId', 'a.status'],
    select: ['a.*', 'b.nickName as username', 'c.title as goodsTitle'],
    join: [
      {
        entity: UserInfoEntity,
        alias: 'b',
        condition: 'a.userId = b.id',
      },
      {
        entity: GoodsInfoEntity,
        alias: 'c',
        condition: 'a.goodsId = c.id',
      },
    ],
  },
})
export class AdminGoodsUserPriceController extends BaseController {
  @Inject()
  goodsUserPriceService: GoodsUserPriceService;
}
